package com.sourceQ.system.controller.message.sms;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sourceQ.common.core.web.controller.BaseController;
import com.sourceQ.common.core.web.domain.AjaxResult;
import com.sourceQ.common.log.annotation.Log;
import com.sourceQ.common.log.enums.BusinessType;
import com.sourceQ.system.dto.message.SmsChannelPageReqDTO;
import com.sourceQ.system.dto.message.SmsChannelSaveReqDTO;
import com.sourceQ.system.service.message.sms.SysSmsChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author: SourceQ
 * @create: 2024-04-26 16:13
 * @Description:短信渠道
 */
@RestController
@RequestMapping("/sms-channel")
@Api(tags = "短信渠道管理")
public class SmsChannelController extends BaseController {

    @Autowired
    private SysSmsChannelService channelService;

    @PostMapping("/create")
    @Log(title = "短信渠道管理",businessType = BusinessType.INSERT)
    @ApiOperation("短信渠道-新增")
    public AjaxResult create(@Valid @RequestBody SmsChannelSaveReqDTO createReqVO){
        return success(channelService.createSmsChannel(createReqVO));
    }
    @PutMapping("/update")
    @Log(title = "短信渠道管理",businessType = BusinessType.UPDATE)
    @ApiOperation("短信渠道-修改")
    public AjaxResult update(@Valid @RequestBody SmsChannelSaveReqDTO updateReqVo){
        channelService.updateSmsChannel(updateReqVo);
        return success();
    }
    @DeleteMapping("/delete/{id}")
    @Log(title = "短信渠道管理",businessType = BusinessType.DELETE)
    @ApiOperation("短信渠道-删除")
    public AjaxResult delete(@PathVariable Long id){
        channelService.deleteSmsChannel(id);
        return success();
    }
    @GetMapping("/detail")
    @Log(title = "短信渠道管理",businessType = BusinessType.QUERY)
    @ApiOperation("短信渠道-详情")
    public AjaxResult detail(@PathVariable Long id){
        return success(channelService.getSmsChannel(id));
    }
    @GetMapping("/page")
    @Log(title = "短信渠道管理",businessType = BusinessType.QUERY)
    @ApiOperation("短信渠道-查询")
    public AjaxResult page(Page page, SmsChannelPageReqDTO pageReqVO){
        return success(channelService.getSmsChannelPage(page, pageReqVO));
    }
    @GetMapping("/list")
    @Log(title = "短信渠道管理",businessType = BusinessType.QUERY)
    @ApiOperation("短信渠道-查询全部")
    public AjaxResult getList(){
        return success(channelService.getSmsChannelList());
    }
}
